home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------------------
-
- FILENAME
- FinishJobMessage.c
-
- DESCRIPTION
- This file contains the message procedure that will be invoked when the Printing Manager
- issues the FinishJob message. The routine which is called is FinishJobMessageProc.
- Depending upon the effects the user selected in the Addition's Print dialog panel,
- FinishJobMessageProc will invoke routines in the Additions.c file to produce the
- desired effects.
-
- COPYRIGHT
- Copyright Apple Computer, Inc. 1991
- All rights reserved.
-
- INTERFACE ROUTINES
- FinishJobMessageProc
-
- MODIFICATION HISTORY
- 05/15/91 ALA Initial Implementation
-
-
- ------------------------------------------------------------------------------- */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Memory.h>
- #include <Resources.h>
- #include <Dialogs.h>
- #include <TextEdit.h>
- #include <OSUtils.h>
- #include <Packages.h>
- #include <ToolUtils.h>
- #include <Menus.h>
- #include <String.h>
- #include <Strings.h>
- #include <Printing.h>
-
- #include <graphics routines.h>
- #include <graphics libraries.h>
- #include <Font Library.h>
-
- #include <Collections.h>
- #include <Messages.h>
-
- #include <PrintingManager.h>
- #include <PrintingMessages.h>
-
- #include "Utilities.h"
- #include "Additions.h"
-
-
- /*================================== MESSAGE INTERFACE ROUTINES ==================================*/
-
-
- /* ===== FinishJobMessageProc =====
-
- FinishJobMessageProc is the extension's routine which will be invoked when Printing issues a
- FinishJob message. This routine checks to see if a cover page should be added
- at the end of the document. If so, it will call ComposeCoverPage
- to generate a page shape, and Send_SpoolPage to spool the cover page to disk.
- Regardless of whether a cover page is added to the file, this routine also calls
- Forward_FinishJob to close down the spool file.
- */
- OSErr FinishJobMessageProc(void)
- {
-
- OSErr anErr = noErr;
- gxShape coverPage = nil;
- Collection jobCollection;
- AdditionsCollection additionsConfig;
-
- gxJob printJob = GXGetJob();
-
- /* Get reference to the print Job's collection */
- jobCollection = GXGetJobCollection(printJob);
-
- /* Fetch the Additions's collection we created at Print dialog time */
- anErr = GetCollectionItem (jobCollection,
- kAdditionsCollectionType,
- gxPrintingTagID,
- nil,
- &additionsConfig);
- if (anErr == noErr)
- {
- /* If user selected the "cover page last" option, add the cover page to the spool file */
- if ( (additionsConfig.addCoverPage) &&
- (additionsConfig.coverPage == kCoverPageLast)
- )
- {
- gxFormat theFormat;
- gxJobInfo printerInfo;
-
- /* Get the format we should use for the cover page */
- theFormat = GXGetJobFormat(printJob, 1);
-
- /* Get the general printing info. collection item */
- anErr = GetCollectionItem (jobCollection,
- gxJobTag,
- gxPrintingTagID,
- nil,
- &printerInfo);
- if (anErr == noErr)
- {
- /* Create the cover page shape */
- anErr = ComposeCoverPage(&coverPage, theFormat, &printerInfo);
- if (anErr == noErr)
- {
- /* Spool the shape into the file */
- anErr = Send_GXPrintPage(theFormat, coverPage);
-
- /* Dump the shape since we no longer need it */
- GXDisposeShape(coverPage);
- }
- }
- }
- }
- else // T => no config; don't do anything
- anErr = noErr;
-
- if (anErr == noErr)
- {
- /* Make sure the job is finished properly */
- anErr = Forward_GXFinishJob();
- }
-
- return(anErr);
- }
- /* FinishJobMessageProc */
-